<template>
  <div class="letter">
    <div class="top111">
      <img @click="fanhui" src="../assets/总图标包含整个系统的/fanhui.png" />
      <span>信息中心</span>
      <img
        class="aaaa"
        src="../assets/总图标包含整个系统的/fanhuishouye.png"
        @click="fanhuish"
      />
    </div>
    <van-tabs
      v-model="active"
      line-width="60px"
      title-active-color="#003399"
      color="#ffcc33"
      @click="onClick"
    >
      <van-tab title="全部消息"></van-tab>
      <van-tab title="系统消息"></van-tab>
      <van-tab title="个人消息"></van-tab>
    </van-tabs>
    <div class="boxxxx">
      <div
        class="content"
        v-for="(item, index) in arr"
        :key="index"
        @click="sdfsadf(item.id)"
      >
        <div class="box">
          <div class="din">
            <img src="../assets/切图/红点.png" v-if="item.isReader == 1" />
          </div>
          <img v-if="item.type == 2" src="../assets/切图/个人信息.png" />
          <img v-else src="../assets/切图/系统消息.png" />

          <div>
            <h4>
              {{ item.title }}
              <img v-if="item.top == 1" src="../assets/切图/置顶.png" />
            </h4>
            <p>
              发布人: <span>{{ item.sourceName }}</span>
            </p>
          </div>
        </div>
        <div class="box_r">
          <span>{{ item.createTime }}</span>
          <img src="../assets/图标/jiantou.png" />
        </div>
      </div>
    </div>
  </div>
</template>
 
<script>
import { GetletterListApi, GetClickList } from "../request/aip";
export default {
  data() {
    return {
      // 当前导航栏显示索引
      active: 0,
      // 详细数据
      arr: [],
    };
  },
  methods: {
    fanhui() {
      this.$router.go(-1);
    },
    fanhuish() {
      this.$router.push("/index");
    },
    onClick() {
      // console.log(this.active);
      GetletterListApi({
        current: "1",
        size: "30",
        type: this.active,
      }).then((res) => {
        // console.log(res);
        this.arr = res.data.records;
      });
    },
    sdfsadf(id) {
      // console.log(id);
      // 点击发送请求  改变已读状态
      GetClickList({ id: id }).then((res) => {
        // console.log(res);
      });
      // return;
      this.$router.push({ name: "Letterlist", params: { id } });
    },
  },
  created() {
    GetletterListApi({
      current: "1",
      size: "20",
      type: this.active,
    }).then((res) => {
      // console.log(res);
      this.arr = res.data.records;
    });
  },
};
</script>
 
<style lang = "less" scoped>
.letter {
  width: 100%;
  height: 100vh;
  background-color: #f5f5f5;
}
.van-tabs {
  background-color: #fff;
}
.boxxxx {
  margin-top: 10px;
}
.content {
  background-color: #fff;
  padding: 20px;
  border-bottom: 1px solid #ccc;
  display: flex;
  justify-content: space-between;
  align-items: center;
  .box {
    display: flex;
    align-items: center;
    .din {
      position: absolute;
      img {
        display: block;
        position: relative;
        width: 10px;
        top: -20px;
        left: 40px;
      }
    }
    img {
      width: 50px;
      margin-right: 10px;
    }
    div {
      h4 {
        img {
          width: 10px;
        }
      }
      p {
        margin-top: 8px;
        font-size: 14px;
        color: #ccc;
      }
    }
  }
  .box_r {
    display: flex;
    align-items: center;
    span {
      font-size: 14px;
      color: #ccc;
      margin-right: 10px;
    }
    img {
      width: 8px;
    }
  }
}
.top111 {
  background-color: #023293;
  display: flex;
  justify-content: space-between;
  color: #fff;
  align-items: center;
  padding: 10px;
  img {
    width: 10px;
  }
  .aaaa {
    width: 20px;
  }
}
</style>